package com.zznj.xzjc.adapter;

import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zznj.xzjc.R;
import com.zznj.xzjc.net.entity.AreaBean;

import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author wx5e48d604c2885118
 * @time 2020/4/7
 */
public class AreaAdapter1 extends BaseQuickAdapter<AreaBean, BaseViewHolder> {

    public AreaAdapter1(int layoutResId, @Nullable List<AreaBean> data) {
        super(layoutResId, data);
    }

    private int selectPosition = -1;
    public void setSelectPosition(int selectPosition){
        this.selectPosition = selectPosition;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, AreaBean item) {
        TextView tv = helper.getView(R.id.tv_title);
        tv.setText(item.getName());
        if(item.getName().equals("返回")){
            tv.setTextColor(mContext.getResources().getColor(R.color.tab_menu_text_select));
            tv.setBackgroundResource(R.drawable.btn_area_select_shape);
        }else{
            if(selectPosition == helper.getAdapterPosition()){
                tv.setTextColor(mContext.getResources().getColor(R.color.tab_menu_text_select));
                tv.setBackgroundResource(R.drawable.btn_area_select_shape);
            }else {
                tv.setTextColor(mContext.getResources().getColor(R.color.color_333333));
                tv.setBackgroundResource(R.drawable.btn_area_unselect_shape);
            }
        }
    }
}
